import moment from 'moment';
const getAssetsFile = (url: string) => {
  return new URL(`../assets/${url}`, import.meta.url).href;
};

const sleep = function (time: number) {
  return new Promise((resolve) => setTimeout(resolve, time));
};

const pageSizes = [10, 20, 50, 100, 200];

enum notifyType {
  success,
  warning,
  info,
  error
}

const statusTypes = [
  {
    name: '启用',
    code: 1
  },
  {
    name: '禁用',
    code: 0
  }
];

//检验项状态：H偏高，P阳性，L偏低，W弱阳，M正常，E错误，U异常
const testItemStatus = {
  H: 'H',
  P: 'P',
  L: 'L',
  W: 'W',
  M: 'M',
  E: 'E',
  U: 'U'
};

function notifyMessage(msg: string, ntype: notifyType, obj: any, duration?: number) {
  obj.$notify({
    title: '提示',
    message: msg,
    offset: 100,
    duration: duration ? duration : 2000, //持续时间
    position: 'bottom-right', //定位在右侧底部
    type: notifyType[ntype]
  });
}

//**日期、时间格式化*/
function formatDateTime(date: any, fmt: string) {
  if (IsEmpty(date)) {
    return;
  }
  const d = new Date(date);
  if (date.toString().lastIndexOf('-') > 0) {
    if (date.toString().lastIndexOf('.') > 0) {
      date = date.toString().substr(0, date.toString().length - 4);
    }
    //d = new Date(date.toString().replace(/\-/g, "/"));
  }
  const o = {
    'M+': d.getMonth() + 1, //月份
    'd+': d.getDate(), //日
    'h+': d.getHours(), //小时
    'm+': d.getMinutes(), //分
    's+': d.getSeconds(), //秒
    'q+': Math.floor((d.getMonth() + 3) / 3), //季度
    'S+': d.getMilliseconds() //毫秒
  } as any;
  if (/(y+)/.test(fmt)) {
    fmt = fmt.replace(RegExp.$1, (d.getFullYear() + '').substr(4 - RegExp.$1.length));
  }
  for (const k in o) {
    if (new RegExp('(' + k + ')').test(fmt)) {
      fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length));
    }
  }
  return fmt;
}

//** 本地日期格式化*/
function DateToString(value) {
  return moment(value).format('YYYY-MM-DD HH:mm:ss');
}

// 时间点快捷选择器
const TimePickerOpts = {
  shortcuts: [
    {
      text: '今天',
      onClick(picker) {
        picker.$emit('pick', new Date());
      }
    },
    {
      text: '昨天',
      onClick(picker) {
        const date = new Date();
        date.setTime(date.getTime() - 3600 * 1000 * 24);
        picker.$emit('pick', date);
      }
    },
    {
      text: '一周前',
      onClick(picker) {
        const date = new Date();
        date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
        picker.$emit('pick', date);
      }
    }
  ]
};

//**判断为空*/
function IsEmpty(value: any) {
  if (value === undefined || value === '' || value === null) {
    return true;
  }
  if (JSON.stringify(value) === '{}' || value === '{}') {
    return true;
  }
  return false;
}

/**验证是都为json 数据 */
function isValidJSON(text: any) {
  try {
    JSON.parse(text);
    return true;
  } catch (error) {
    return false;
  }
}

//**生成空GUID */
function EmptyUUID() {
  return '00000000-0000-0000-0000-000000000000';
}
//**生成 */
function newGuid() {
  function S4() {
    return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
  }
  return S4() + S4() + '-' + S4() + '-' + S4() + '-' + S4() + '-' + S4() + S4() + S4();
}

// 校验手机号 是否手机号码或者固话
function validatePhoneTwo(rule, value, callback) {
  const reg = /^((0\d{2,3}-\d{7,8})|(1[34578]\d{9}))$/;
  if (value == '' || value == undefined || value == null) {
    callback();
  } else {
    if (!reg.test(value) && value != '') {
      callback(new Error('请输入正确的电话号码或者固话号码'));
    } else {
      callback();
    }
  }
}

// 校验邮箱
function validateEMail(rule, value, callback) {
  const reg = /^([a-zA-Z0-9]+[-_\.]?)+@[a-zA-Z0-9]+\.[a-z]+$/;
  if (value == '' || value == undefined || value == null) {
    callback();
  } else {
    if (!reg.test(value)) {
      callback(new Error('请输入正确的邮箱'));
    } else {
      callback();
    }
  }
}

// 校验身份证号
function validateID(rule, value, callback) {
  const reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
  if (value == '' || value == undefined || value == null) {
    callback();
  } else {
    if (!reg.test(value)) {
      callback(new Error('请输入正确的身份证号'));
    } else {
      callback();
    }
  }
}

/**
 * 编号自增
 */
function autoIncrementNumber(curNum: string, type = '+') {
  var letters = curNum.replace(/\d+/g, '');
  var numbers = curNum.match(/\d+/g);
  if (!numbers) {
    return curNum;
  }
  var lastNumber = parseInt(numbers[numbers.length - 1], 10);
  if (type === '+') {
    lastNumber++;
  }
  if (type === '-') {
    lastNumber--;
    lastNumber = lastNumber <= 1 ? 1 : lastNumber;
  }

  var nextNumber = lastNumber.toString();
  if (nextNumber.length < numbers[numbers.length - 1].length) {
    var leadingZeros = numbers[numbers.length - 1].length - nextNumber.length;
    if (lastNumber <= 9 && letters.length <= 0) {
      leadingZeros = 0;
    }
    nextNumber = /\D/.test(curNum) ? '0'.repeat(leadingZeros) + nextNumber : nextNumber;
  }
  var nextCode = letters + nextNumber;
  return nextCode;
  // const regex = /([A-Z]+)(\d+)/g;
  // const matches = regex.exec(curNum);
  // let prefix = matches ? matches[1] : curNum;
  // let number = parseInt(matches ? matches[2] : curNum) + 1;
  // let nextID = prefix + number.toString().padStart((matches ? matches[2] : curNum).length, '0');
  // return nextID;
}

/**排序算法 */
function sortByField(arr: any[], field: string, type = 'asc') {
  arr.forEach((a: any) => {
    if (a && (field === null || field === undefined || field === '')) {
      a[field] = '';
    }
    if (a && field !== null && field !== undefined && field !== '' && typeof a[field] !== 'number') {
      let s = a[field];
      if (!IsEmpty(s)) {
        s = s.replace(/a/g, '01');
        s = s.replace(/b/g, '02');
        s = s.replace(/c/g, '03');
        s = s.replace(/d/g, '04');
        s = s.replace(/e/g, '05');
        s = s.replace(/f/g, '06');
        s = s.replace(/g/g, '07');
        s = s.replace(/h/g, '08');
        s = s.replace(/i/g, '09');
        s = s.replace(/j/g, '10');
        s = s.replace(/k/g, '11');
        s = s.replace(/l/g, '12');
        s = s.replace(/m/g, '13');
        s = s.replace(/n/g, '14');
        s = s.replace(/o/g, '15');
        s = s.replace(/p/g, '16');
        s = s.replace(/q/g, '17');
        s = s.replace(/r/g, '18');
        s = s.replace(/s/g, '19');
        s = s.replace(/t/g, '20');
        s = s.replace(/u/g, '21');
        s = s.replace(/v/g, '22');
        s = s.replace(/w/g, '23');
        s = s.replace(/x/g, '24');
        s = s.replace(/y/g, '25');
        s = s.replace(/z/g, '26');
        s = s.replace(/A/g, '27');
        s = s.replace(/B/g, '28');
        s = s.replace(/C/g, '29');
        s = s.replace(/D/g, '30');
        s = s.replace(/E/g, '31');
        s = s.replace(/F/g, '32');
        s = s.replace(/G/g, '33');
        s = s.replace(/H/g, '34');
        s = s.replace(/I/g, '35');
        s = s.replace(/J/g, '36');
        s = s.replace(/K/g, '37');
        s = s.replace(/L/g, '38');
        s = s.replace(/M/g, '39');
        s = s.replace(/N/g, '40');
        s = s.replace(/O/g, '41');
        s = s.replace(/P/g, '42');
        s = s.replace(/Q/g, '43');
        s = s.replace(/R/g, '44');
        s = s.replace(/S/g, '45');
        s = s.replace(/T/g, '46');
        s = s.replace(/U/g, '47');
        s = s.replace(/V/g, '48');
        s = s.replace(/W/g, '49');
        s = s.replace(/X/g, '50');
        s = s.replace(/Y/g, '51');
        s = s.replace(/Z/g, '52');
      }
      //a[field] = s.padStart(20, '0');
    }
  });
  arr.sort((a, b) => {
    return type === 'asc' ? a[field] - b[field] : b[field] - a[field];
  });
  return arr;
}

function clearFormData(form: any) {
  Object.keys(form).forEach((key) => {
    if (typeof form[key] === 'string') {
      form[key] = '';
    } else if (typeof form[key] === 'number') {
      form[key] = 0;
    } else if (form[key] instanceof Array) {
      form[key].length = 0;
    }
  });
}

// 获取民族基本信息
function getNationality() {
  return [
    {
      id: '01',
      text: '汉族',
      value: 'Han'
    },
    {
      id: '02',
      text: '壮族',
      value: 'Zhuang'
    },
    {
      id: '03',
      text: '回族',
      value: 'Hui'
    },
    {
      id: '04',
      text: '藏族',
      value: 'Tibetan'
    },
    {
      id: '05',
      text: '维吾尔族',
      value: 'Uighur '
    },
    {
      id: '06',
      text: '苗族',
      value: 'Miao'
    },
    {
      id: '07',
      text: '彝族',
      value: 'Yi'
    },
    {
      id: '08',
      text: '蒙古族',
      value: 'Mongol'
    },
    {
      id: '09',
      text: '布依族',
      value: 'Buyi'
    },
    {
      id: '10',
      text: '朝鲜族',
      value: 'Korean'
    },
    {
      id: '11',
      text: '满族',
      value: 'Manchu'
    },
    {
      id: '12',
      text: '侗族',
      value: 'Dong'
    },
    {
      id: '13',
      text: '瑶族',
      value: 'Yao'
    },
    {
      id: '14',
      text: '白族',
      value: 'Bai'
    },
    {
      id: '15',
      text: '土家族',
      value: 'Tujia'
    },
    {
      id: '16',
      text: '哈尼族',
      value: 'Hani'
    },
    {
      id: '17',
      text: '哈萨克族',
      value: 'Kazakh'
    },
    {
      id: '18',
      text: '傣族',
      value: 'Dai'
    },
    {
      id: '19',
      text: '黎族',
      value: 'Li'
    },
    {
      id: '20',
      text: '傈僳族',
      value: 'Lisu'
    },
    {
      id: '21',
      text: '佤族',
      value: 'Wa'
    },
    {
      id: '22',
      text: '畲族',
      value: 'She'
    },
    {
      id: '23',
      text: '高山族',
      value: 'Gaoshan'
    },
    {
      id: '24',
      text: '拉祜族',
      value: 'Lahu'
    },
    {
      id: '25',
      text: '水族',
      value: 'Shui'
    },
    {
      id: '26',
      text: '东乡族',
      value: 'Dongxiang'
    },
    {
      id: '27',
      text: '纳西族',
      value: 'Naxi'
    },
    {
      id: '28',
      text: '景颇族',
      value: 'Jingpo'
    },
    {
      id: '29',
      text: '柯尔克孜族',
      value: 'Kirghiz'
    },
    {
      id: '30',
      text: '土族',
      value: 'Tu'
    },
    {
      id: '31',
      text: '达斡尔族',
      value: 'Daur'
    },
    {
      id: '32',
      text: '仫佬族',
      value: 'Mulam'
    },
    {
      id: '33',
      text: '羌族',
      value: 'Qiang'
    },
    {
      id: '34',
      text: '布朗族',
      value: 'Blang'
    },
    {
      id: '35',
      text: '撒拉族',
      value: 'Salar'
    },
    {
      id: '36',
      text: '毛南族',
      value: 'Maonan'
    },
    {
      id: '37',
      text: '仡佬族',
      value: 'Gelao'
    },
    {
      id: '38',
      text: '锡伯族',
      value: 'Xibe'
    },
    {
      id: '39',
      text: '阿昌族',
      value: 'Achang'
    },
    {
      id: '40',
      text: '普米族',
      value: 'Pumi'
    },
    {
      id: '41',
      text: '塔吉克族',
      value: 'Tajik'
    },
    {
      id: '42',
      text: '怒族',
      value: 'Nu'
    },
    {
      id: '43',
      text: '乌孜别克族',
      value: 'Uzbek'
    },
    {
      id: '44',
      text: '俄罗斯族',
      value: 'Russian'
    },
    {
      id: '45',
      text: '鄂温克族',
      value: 'Evenki'
    },
    {
      id: '46',
      text: '崩龙族(得昂族)',
      value: 'Bumloon'
    },
    {
      id: '47',
      text: '保安族',
      value: 'Bonan'
    },
    {
      id: '48',
      text: '裕固族',
      value: 'Yugur'
    },
    {
      id: '49',
      text: '京族',
      value: 'Gin'
    },
    {
      id: '50',
      text: '塔塔尔族',
      value: 'Tatar'
    },
    {
      id: '51',
      text: '独龙族',
      value: 'Drung'
    },
    {
      id: '52',
      text: '鄂伦春族',
      value: 'Oroqin'
    },
    {
      id: '53',
      text: '赫哲族',
      value: 'Hezhen'
    },
    {
      id: '54',
      text: '门巴族',
      value: 'Menba'
    },
    {
      id: '55',
      text: '珞巴族',
      value: 'Lhobo'
    },
    {
      id: '56',
      text: '基诺族',
      value: 'Jino'
    }
  ];
}

function getProvince() {
  return [
    { name: '安徽省', code: '340000' },
    { name: '北京市', code: '110000' },
    { name: '福建省', code: '350000' },
    { name: '甘肃省', code: '620000' },
    { name: '广东省', code: '440000' },
    { name: '广西壮族自治区', code: '450000' },
    { name: '贵州省', code: '520000' },
    { name: '海南省', code: '460000' },
    { name: '河北省', code: '130000' },
    { name: '河南省', code: '410000' },
    { name: '黑龙江省', code: '230000' },
    { name: '湖北省', code: '420000' },
    { name: '湖南省', code: '430000' },
    { name: '吉林省', code: '220000' },
    { name: '江苏省', code: '320000' },
    { name: '江西省', code: '360000' },
    { name: '辽宁省', code: '210000' },
    { name: '内蒙古自治区', code: '150000' },
    { name: '宁夏回族自治区', code: '640000' },
    { name: '青海省', code: '630000' },
    { name: '山东省', code: '370000' },
    { name: '山西省', code: '140000' },
    { name: '陕西省', code: '610000' },
    { name: '上海市', code: '310000' },
    { name: '四川省', code: '510000' },
    { name: '天津市', code: '120000' },
    { name: '西藏自治区', code: '540000' },
    { name: '新疆维吾尔自治区', code: '650000' },
    { name: '云南省', code: '530000' },
    { name: '浙江省', code: '330000' },
    { name: '重庆市', code: '500000' }
  ];
}

function getCity() {
  return [
    { name: '安庆市', code: '340800' },
    { name: '蚌埠市', code: '340300' },
    { name: '巢湖市', code: '341400' },
    { name: '池州市', code: '341700' },
    { name: '滁州市', code: '341100' },
    { name: '阜阳市', code: '341200' },
    { name: '合肥市', code: '340100' },
    { name: '淮北市', code: '340600' },
    { name: '淮南市', code: '340400' },
    { name: '黄山市', code: '341000' },
    { name: '六安市', code: '341500' },
    { name: '马鞍山市', code: '340500' },
    { name: '宿州市', code: '341300' },
    { name: '铜陵市', code: '340700' },
    { name: '芜湖市', code: '340200' },
    { name: '宣城市', code: '341800' },
    { name: '亳州市', code: '341600' },
    { name: '市辖区', code: '110100' },
    { name: '县', code: '110200' },
    { name: '福州市', code: '350100' },
    { name: '龙岩市', code: '350800' },
    { name: '南平市', code: '350700' },
    { name: '宁德市', code: '350900' },
    { name: '莆田市', code: '350300' },
    { name: '泉州市', code: '350500' },
    { name: '三明市', code: '350400' },
    { name: '厦门市', code: '350200' },
    { name: '漳州市', code: '350600' },
    { name: '白银市', code: '620400' },
    { name: '定西市', code: '621100' },
    { name: '甘南藏族自治州', code: '623000' },
    { name: '嘉峪关市', code: '620200' },
    { name: '金昌市', code: '620300' },
    { name: '酒泉市', code: '620900' },
    { name: '兰州市', code: '620100' },
    { name: '临夏回族自治州', code: '622900' },
    { name: '陇南市', code: '621200' },
    { name: '平凉市', code: '620800' },
    { name: '庆阳市', code: '621000' },
    { name: '天水市', code: '620500' },
    { name: '武威市', code: '620600' },
    { name: '张掖市', code: '620700' },
    { name: '潮州市', code: '445100' },
    { name: '东莞市', code: '441900' },
    { name: '佛山市', code: '440600' },
    { name: '广州市', code: '440100' },
    { name: '河源市', code: '441600' },
    { name: '惠州市', code: '441300' },
    { name: '江门市', code: '440700' },
    { name: '揭阳市', code: '445200' },
    { name: '茂名市', code: '440900' },
    { name: '梅州市', code: '441400' },
    { name: '清远市', code: '441800' },
    { name: '汕头市', code: '440500' },
    { name: '汕尾市', code: '441500' },
    { name: '韶关市', code: '440200' },
    { name: '深圳市', code: '440300' },
    { name: '阳江市', code: '441700' },
    { name: '云浮市', code: '445300' },
    { name: '湛江市', code: '440800' },
    { name: '肇庆市', code: '441200' },
    { name: '中山市', code: '442000' },
    { name: '珠海市', code: '440400' },
    { name: '百色市', code: '451000' },
    { name: '北海市', code: '450500' },
    { name: '崇左市', code: '451400' },
    { name: '防城港市', code: '450600' },
    { name: '桂林市', code: '450300' },
    { name: '贵港市', code: '450800' },
    { name: '河池市', code: '451200' },
    { name: '贺州市', code: '451100' },
    { name: '来宾市', code: '451300' },
    { name: '柳州市', code: '450200' },
    { name: '南宁市', code: '450100' },
    { name: '钦州市', code: '450700' },
    { name: '梧州市', code: '450400' },
    { name: '玉林市', code: '450900' },
    { name: '安顺市', code: '520400' },
    { name: '毕节地区', code: '522400' },
    { name: '贵阳市', code: '520100' },
    { name: '六盘水市', code: '520200' },
    { name: '黔东南苗族侗族自治州', code: '522600' },
    { name: '黔南布依族苗族自治州', code: '522700' },
    { name: '黔西南布依族苗族自治州', code: '522300' },
    { name: '铜仁地区', code: '522200' },
    { name: '遵义市', code: '520300' },
    { name: '海口市', code: '460100' },
    { name: '三亚市', code: '460200' },
    { name: '省直辖县级行政单位', code: '469000' },
    { name: '保定市', code: '130600' },
    { name: '沧州市', code: '130900' },
    { name: '承德市', code: '130800' },
    { name: '邯郸市', code: '130400' },
    { name: '衡水市', code: '131100' },
    { name: '廊坊市', code: '131000' },
    { name: '秦皇岛市', code: '130300' },
    { name: '石家庄市', code: '130100' },
    { name: '唐山市', code: '130200' },
    { name: '邢台市', code: '130500' },
    { name: '张家口市', code: '130700' },
    { name: '安阳市', code: '410500' },
    { name: '鹤壁市', code: '410600' },
    { name: '焦作市', code: '410800' },
    { name: '开封市', code: '410200' },
    { name: '洛阳市', code: '410300' },
    { name: '南阳市', code: '411300' },
    { name: '平顶山市', code: '410400' },
    { name: '三门峡市', code: '411200' },
    { name: '商丘市', code: '411400' },
    { name: '新乡市', code: '410700' },
    { name: '信阳市', code: '411500' },
    { name: '许昌市', code: '411000' },
    { name: '郑州市', code: '410100' },
    { name: '周口市', code: '411600' },
    { name: '驻马店市', code: '411700' },
    { name: '漯河市', code: '411100' },
    { name: '濮阳市', code: '410900' },
    { name: '大庆市', code: '230600' },
    { name: '大兴安岭地区', code: '232700' },
    { name: '哈尔滨市', code: '230100' },
    { name: '鹤岗市', code: '230400' },
    { name: '黑河市', code: '231100' },
    { name: '鸡西市', code: '230300' },
    { name: '佳木斯市', code: '230800' },
    { name: '牡丹江市', code: '231000' },
    { name: '七台河市', code: '230900' },
    { name: '齐齐哈尔市', code: '230200' },
    { name: '双鸭山市', code: '230500' },
    { name: '绥化市', code: '231200' },
    { name: '伊春市', code: '230700' },
    { name: '鄂州市', code: '420700' },
    { name: '恩施土家族苗族自治州', code: '422800' },
    { name: '黄冈市', code: '421100' },
    { name: '黄石市', code: '420200' },
    { name: '荆门市', code: '420800' },
    { name: '荆州市', code: '421000' },
    { name: '省直辖行政单位', code: '429000' },
    { name: '十堰市', code: '420300' },
    { name: '随州市', code: '421300' },
    { name: '武汉市', code: '420100' },
    { name: '咸宁市', code: '421200' },
    { name: '襄樊市', code: '420600' },
    { name: '孝感市', code: '420900' },
    { name: '宜昌市', code: '420500' },
    { name: '常德市', code: '430700' },
    { name: '长沙市', code: '430100' },
    { name: '郴州市', code: '431000' },
    { name: '衡阳市', code: '430400' },
    { name: '怀化市', code: '431200' },
    { name: '娄底市', code: '431300' },
    { name: '邵阳市', code: '430500' },
    { name: '湘潭市', code: '430300' },
    { name: '湘西土家族苗族自治州', code: '433100' },
    { name: '益阳市', code: '430900' },
    { name: '永州市', code: '431100' },
    { name: '岳阳市', code: '430600' },
    { name: '张家界市', code: '430800' },
    { name: '株洲市', code: '430200' },
    { name: '白城市', code: '220800' },
    { name: '白山市', code: '220600' },
    { name: '长春市', code: '220100' },
    { name: '吉林市', code: '220200' },
    { name: '辽源市', code: '220400' },
    { name: '四平市', code: '220300' },
    { name: '松原市', code: '220700' },
    { name: '通化市', code: '220500' },
    { name: '延边朝鲜族自治州', code: '222400' },
    { name: '常州市', code: '320400' },
    { name: '淮安市', code: '320800' },
    { name: '连云港市', code: '320700' },
    { name: '南京市', code: '320100' },
    { name: '南通市', code: '320600' },
    { name: '苏州市', code: '320500' },
    { name: '宿迁市', code: '321300' },
    { name: '泰州市', code: '321200' },
    { name: '无锡市', code: '320200' },
    { name: '徐州市', code: '320300' },
    { name: '盐城市', code: '320900' },
    { name: '扬州市', code: '321000' },
    { name: '镇江市', code: '321100' },
    { name: '抚州市', code: '361000' },
    { name: '赣州市', code: '360700' },
    { name: '吉安市', code: '360800' },
    { name: '景德镇市', code: '360200' },
    { name: '九江市', code: '360400' },
    { name: '南昌市', code: '360100' },
    { name: '萍乡市', code: '360300' },
    { name: '上饶市', code: '361100' },
    { name: '新余市', code: '360500' },
    { name: '宜春市', code: '360900' },
    { name: '鹰潭市', code: '360600' },
    { name: '鞍山市', code: '210300' },
    { name: '本溪市', code: '210500' },
    { name: '朝阳市', code: '211300' },
    { name: '大连市', code: '210200' },
    { name: '丹东市', code: '210600' },
    { name: '抚顺市', code: '210400' },
    { name: '阜新市', code: '210900' },
    { name: '葫芦岛市', code: '211400' },
    { name: '锦州市', code: '210700' },
    { name: '辽阳市', code: '211000' },
    { name: '盘锦市', code: '211100' },
    { name: '沈阳市', code: '210100' },
    { name: '铁岭市', code: '211200' },
    { name: '营口市', code: '210800' },
    { name: '阿拉善盟', code: '152900' },
    { name: '巴彦淖尔市', code: '150800' },
    { name: '包头市', code: '150200' },
    { name: '赤峰市', code: '150400' },
    { name: '鄂尔多斯市', code: '150600' },
    { name: '呼和浩特市', code: '150100' },
    { name: '呼伦贝尔市', code: '150700' },
    { name: '通辽市', code: '150500' },
    { name: '乌海市', code: '150300' },
    { name: '乌兰察布市', code: '150900' },
    { name: '锡林郭勒盟', code: '152500' },
    { name: '兴安盟', code: '152200' },
    { name: '固原市', code: '640400' },
    { name: '石嘴山市', code: '640200' },
    { name: '吴忠市', code: '640300' },
    { name: '银川市', code: '640100' },
    { name: '中卫市', code: '640500' },
    { name: '果洛藏族自治州', code: '632600' },
    { name: '海北藏族自治州', code: '632200' },
    { name: '海东地区', code: '632100' },
    { name: '海南藏族自治州', code: '632500' },
    { name: '海西蒙古族藏族自治州', code: '632800' },
    { name: '黄南藏族自治州', code: '632300' },
    { name: '西宁市', code: '630100' },
    { name: '玉树藏族自治州', code: '632700' },
    { name: '滨州市', code: '371600' },
    { name: '德州市', code: '371400' },
    { name: '东营市', code: '370500' },
    { name: '菏泽市', code: '371700' },
    { name: '济南市', code: '370100' },
    { name: '济宁市', code: '370800' },
    { name: '莱芜市', code: '371200' },
    { name: '聊城市', code: '371500' },
    { name: '临沂市', code: '371300' },
    { name: '青岛市', code: '370200' },
    { name: '日照市', code: '371100' },
    { name: '泰安市', code: '370900' },
    { name: '威海市', code: '371000' },
    { name: '潍坊市', code: '370700' },
    { name: '烟台市', code: '370600' },
    { name: '枣庄市', code: '370400' },
    { name: '淄博市', code: '370300' },
    { name: '长治市', code: '140400' },
    { name: '大同市', code: '140200' },
    { name: '晋城市', code: '140500' },
    { name: '晋中市', code: '140700' },
    { name: '临汾市', code: '141000' },
    { name: '吕梁市', code: '141100' },
    { name: '朔州市', code: '140600' },
    { name: '太原市', code: '140100' },
    { name: '忻州市', code: '140900' },
    { name: '阳泉市', code: '140300' },
    { name: '运城市', code: '140800' },
    { name: '安康市', code: '610900' },
    { name: '宝鸡市', code: '610300' },
    { name: '汉中市', code: '610700' },
    { name: '商洛市', code: '611000' },
    { name: '铜川市', code: '610200' },
    { name: '渭南市', code: '610500' },
    { name: '西安市', code: '610100' },
    { name: '咸阳市', code: '610400' },
    { name: '延安市', code: '610600' },
    { name: '榆林市', code: '610800' },
    { name: '市辖区', code: '310100' },
    { name: '县', code: '310200' },
    { name: '阿坝藏族羌族自治州', code: '513200' },
    { name: '巴中市', code: '511900' },
    { name: '成都市', code: '510100' },
    { name: '达州市', code: '511700' },
    { name: '德阳市', code: '510600' },
    { name: '甘孜藏族自治州', code: '513300' },
    { name: '广安市', code: '511600' },
    { name: '广元市', code: '510800' },
    { name: '乐山市', code: '511100' },
    { name: '凉山彝族自治州', code: '513400' },
    { name: '眉山市', code: '511400' },
    { name: '绵阳市', code: '510700' },
    { name: '南充市', code: '511300' },
    { name: '内江市', code: '511000' },
    { name: '攀枝花市', code: '510400' },
    { name: '遂宁市', code: '510900' },
    { name: '雅安市', code: '511800' },
    { name: '宜宾市', code: '511500' },
    { name: '资阳市', code: '512000' },
    { name: '自贡市', code: '510300' },
    { name: '泸州市', code: '510500' },
    { name: '市辖区', code: '120100' },
    { name: '县', code: '120200' },
    { name: '阿里地区', code: '542500' },
    { name: '昌都地区', code: '542100' },
    { name: '拉萨市', code: '540100' },
    { name: '林芝地区', code: '542600' },
    { name: '那曲地区', code: '542400' },
    { name: '日喀则地区', code: '542300' },
    { name: '山南地区', code: '542200' },
    { name: '阿克苏地区', code: '652900' },
    { name: '阿勒泰地区', code: '654300' },
    { name: '巴音郭楞蒙古自治州', code: '652800' },
    { name: '博尔塔拉蒙古自治州', code: '652700' },
    { name: '昌吉回族自治州', code: '652300' },
    { name: '哈密地区', code: '652200' },
    { name: '和田地区', code: '653200' },
    { name: '喀什地区', code: '653100' },
    { name: '克拉玛依市', code: '650200' },
    { name: '克孜勒苏柯尔克孜自治州', code: '653000' },
    { name: '省直辖行政单位', code: '659000' },
    { name: '石河子市', code: '650300' },
    { name: '塔城地区', code: '654200' },
    { name: '吐鲁番地区', code: '652100' },
    { name: '乌鲁木齐市', code: '650100' },
    { name: '伊犁哈萨克自治州', code: '654000' },
    { name: '保山市', code: '530500' },
    { name: '楚雄彝族自治州', code: '532300' },
    { name: '大理白族自治州', code: '532900' },
    { name: '德宏傣族景颇族自治州', code: '533100' },
    { name: '迪庆藏族自治州', code: '533400' },
    { name: '红河哈尼族彝族自治州', code: '532500' },
    { name: '昆明市', code: '530100' },
    { name: '丽江市', code: '530700' },
    { name: '临沧市', code: '530900' },
    { name: '怒江傈僳族自治州', code: '533300' },
    { name: '曲靖市', code: '530300' },
    { name: '思茅市', code: '530800' },
    { name: '文山壮族苗族自治州', code: '532600' },
    { name: '西双版纳傣族自治州', code: '532800' },
    { name: '玉溪市', code: '530400' },
    { name: '昭通市', code: '530600' },
    { name: '杭州市', code: '330100' },
    { name: '湖州市', code: '330500' },
    { name: '嘉兴市', code: '330400' },
    { name: '金华市', code: '330700' },
    { name: '丽水市', code: '331100' },
    { name: '宁波市', code: '330200' },
    { name: '绍兴市', code: '330600' },
    { name: '台州市', code: '331000' },
    { name: '温州市', code: '330300' },
    { name: '舟山市', code: '330900' },
    { name: '衢州市', code: '330800' },
    { name: '市辖区', code: '500100' },
    { name: '县', code: '500200' }
  ];
}

/**分割数组，保证打印机平顺打印 */
function splitArray(arr: any) {
  // 初始化分割后的数组结果
  let result = [];
  // 定义每个子数组需要的元素数目，依次是 1, 3, 5, 7, 9
  let sizes = [1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9];
  // 跟踪当前数组的索引
  let index = 0;

  // 遍历数组并进行分组
  for (let size of sizes) {
    // 如果数组元素不够分割时，跳出循环并把剩余元素全放入最后一个数组
    if (index >= arr.length) {
      break;
    }

    // 计算剩余的元素个数
    let remaining = arr.length - index;
    // 如果剩余的元素不足以分割，则全都放入最后一个数组
    if (remaining <= size) {
      result.push(arr.slice(index));
      break;
    }

    // 将当前分组放入结果数组中
    result.push(arr.slice(index, index + size));
    // 更新索引到下一个分组的开始位置
    index += size;
  }

  return result;
}

/**判断Reactive  为空 */
function IsReactiveEmpty(obj: any) {
  if (Object.keys(obj).length === 0) {
    return true;
  }
  if (obj === null) {
    return true;
  }
  if (obj === undefined) {
    return true;
  }
  if (obj === '') {
    return true;
  }
  return false;
}

/**计算时间差 */
function calculateTimeDifference(startDate, endDate) {
  // 转换为时间戳（毫秒）
  const start = new Date(startDate).getTime();
  const end = new Date(endDate).getTime();

  // 计算时间差，单位为毫秒
  const diff = end - start;

  // 计算相差的天数
  const days = Math.floor(diff / (1000 * 60 * 60 * 24));

  // 计算剩余的小时数
  const hours = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));

  //计算剩余的分钟数
  const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60));
  console.log(minutes);
  
  return { days: days, hours: hours, minutes: minutes };
}

export { getAssetsFile, sleep, pageSizes, notifyType, notifyMessage, statusTypes, testItemStatus, formatDateTime, DateToString, IsEmpty, isValidJSON, EmptyUUID, newGuid, validatePhoneTwo, validateEMail, validateID, autoIncrementNumber, TimePickerOpts, sortByField, getNationality, getProvince, getCity, splitArray, IsReactiveEmpty, calculateTimeDifference };
